#include "Player.h"




Player::Player()
{
	pos.x = 0; pos.y = 0;
	Velocity.x = 0; Velocity.y = 0;
	aimAngle = PI / 2;
}

Player::Player(XY startPos) // : Entity::pos(startPos)
{

	shotCoolDown = 0;
	shotCoolDownMax = 0.5;

	

	Velocity.x = 0; Velocity.y = 0;
	ownedBullets = new std::vector<Bullet*>;
	pos = startPos;
	//aim.x = 0; aim.y = 1.0; //VON: start with aim up?
	aimAngle =- PI / 2.0;
	health = 3; //using 3 as standards health amount, takes 3 collisions with bullets to kill a player, only takes one asteroid collision
	ammo = 5;   //starting with 5 for star
}

void Player::RotateClockwise(float deltaTime)
{
	Rotate(deltaTime * 4); //
}
void Player::RotateCounterclockwise(float deltaTime)
{
	Rotate(-1 * (deltaTime * 4) );
}

void Player::GoFast(){	SetMagAccordingToAngleXY(Velocity, aimAngle, 70.0f); }
void Player::GoSlow(){  SetMagAccordingToAngleXY(Velocity, aimAngle, 8.2f);  }

void Player::Rotate(float angle)
{
	aimAngle += angle;
}
//std::vector<Bullet*>* bv
void Player::SetBulletVec(std::vector<Bullet*>* bv)
{
	ownedBullets = bv;
}
void Player::Shoot()
{
	//if(ammo <= 0) return;  ammo --;
	if(shotCoolDown <= 0)
	{

		
		ownedBullets->push_back(new Bullet(pos, aimAngle));
		shotCoolDown = shotCoolDownMax;
	}

}

void Player::TakeHit()
{
	health--;
}

void Player::Kill()
{
	health = 0;
}

XY Player::GetPos()
{
	return pos;
}

XY Player::GetCenterPos()
{
	return pos;
}

int Player::GetHealth()
{
	return health;
}

bool Player::IsDead()
{
	return health <= 0;
}

void Player::Update(float deltaTime)
{
	shotCoolDown-= deltaTime;
	Entity::Update(deltaTime);
}
/*
class Player : public Entity
{
private:
	float aimAngle;
	int health;
	int ammo;
	std::vector<Bullet*>* ownedBullets;
	//BulletList magazine
public:
	Player(XY startPos); // VON starting coords
	void Shoot();
	void Rotate(int angle);
	void TakeHit(); //VON -- if a bullet collides with the player, destroy the bullet and cause that player to Take a Hit from its health
};
*
*/